package archer.back.models

sealed trait AbsStatus

trait Pass extends AbsStatus

trait Failed extends AbsStatus

trait Equ[A] {
  type B <: AbsStatus
}

object Equ {

  type Aux[E, K <: AbsStatus] = Equ[E] { type B = K }

  implicit def equImplicit1: Aux[String, Failed] = new Equ[String] {
    override type B = Failed
  }
  def equPass[T]: Aux[T, Pass] = new Equ[T] {
    override type B = Pass
  }

}

trait ValueWrap[E, V] {

  def extract(implicit impl: V <:< Pass): E

}

object Fabc {

  def aa[T, S <: AbsStatus](s: T)(implicit equImpl: Equ.Aux[T, S] = Equ.equPass[T]): ValueWrap[String, equImpl.B] = {
    new ValueWrap[String, equImpl.B] {
      override def extract(implicit impl: equImpl.B <:< Pass): String = {
        s.toString
      }
    }
  }

  aa(2333).extract
  aa(BigDecimal("1234")).extract
  //aa("1234").extract //Error: Cannot prove that archer.back.models.Failed <:< archer.back.models.Pass.

}
